#!/bin/bash

#让sudo命令生效
echo rock | sudo -S ls

my_count=1

demoFun(){
    echo "这是${my_count} 个 shell 函数!"
	  sudo xrandr --newmode "640x1280_${my_count}"  76.30  640 $1 $2 $3  1280 $4 $5 $6  -HSync +Vsync
    sudo xrandr --addmode HDMI-1 640x1280_"${my_count}"
    sudo xrandr --output HDMI-1 --mode 640x1280_"${my_count}"
    ((my_count++))
}

echo "-----函数开始执行-----"

ratio_arrayA1=(680 681 682)
ratio_arrayA2=(752 754)
ratio_arrayA3=(864)

ratio_arrayB1=(1281 1282 1283)
ratio_arrayB2=(1284 1286)
ratio_arrayB3=(1330)
#获取数组中的所有元素: 使用@ 或 * 可以获取数组中的所有元素
for r_a1 in ${ratio_arrayA1[*]}; do
    for r_a2 in ${ratio_arrayA2[*]}; do
    for r_a3 in ${ratio_arrayA3[*]}; do
    for r_b1 in ${ratio_arrayB1[*]}; do
    for r_b2 in ${ratio_arrayB2[*]}; do
    for r_b3 in ${ratio_arrayB3[*]}; do
    echo "ratio_arrayA1 : ${r_a1}"
    echo "ratio_arrayA2 : ${r_a2}"
    echo "ratio_arrayA3 : ${r_a3}"
    echo "ratio_arrayB1 : ${r_b1}"
    echo "ratio_arrayB2 : ${r_b2}"
    echo "ratio_arrayB3 : ${r_b3}"
    demoFun ${r_a1} ${r_a2} ${r_a3} ${r_b1} ${r_b2} ${r_b3}
    # 延时 x 秒
    sleep 5
done
done
done
done
done
done

echo "-----函数执行完毕-----"
